Skip to content

Reduce value type boxing in interop calls#787

Merged
sebastienros merged 2 commits intosebastienros:mainfrom
lahma:reduce-interop-boxing
Apr 27, 2025
Merged

Reduce value type boxing in interop calls#787
sebastienros merged 2 commits intosebastienros:mainfrom
lahma:reduce-interop-boxing

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Apr 27, 2025

  • special case common bool and int property access
  • use abstract class instead of interface do reduce virtual dispatch cost

When profiling NJsonSchema, found out that now after optimizations almost 10% of allocations originate from boolean value boxing (very common in code generation templates).

image

* special case common bool and int property access
* use abstract class instead of interface do reduce virtual dispatch cost
@lahma lahma force-pushed the reduce-interop-boxing branch from 89a7e90 to 8175a98 Compare April 27, 2025 15:22
@lahma lahma force-pushed the reduce-interop-boxing branch from 8175a98 to fe7c7ad Compare April 27, 2025 15:24
@sebastienros
Copy link
Copy Markdown
Owner

Did you check what I did in the other branch I mentioned last time? Similar to skip the boxing, but did it for any common type. Not the new specific classes though.

@sebastienros sebastienros merged commit 9b11031 into sebastienros:main Apr 27, 2025
1 check passed
@lahma lahma deleted the reduce-interop-boxing branch April 28, 2025 06:11
@lahma
Copy link
Copy Markdown
Collaborator Author

lahma commented Apr 28, 2025

Did you check what I did in the other branch I mentioned last time? Similar to skip the boxing, but did it for any common type. Not the new specific classes though.

No I didn't notice that one, it's quite big diff. Maybe you could bring improvements from there in smaller batches?

@sebastienros
Copy link
Copy Markdown
Owner

No, it's a big breaking change, the goal is to ship a 3.0 with it. I'll move your improvements there though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants